package project.dade.cn.bst.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.widget.ImageView;

import com.bumptech.glide.Glide;

import java.util.ArrayList;

import butterknife.InjectView;
import cn.bingoogolapple.androidcommon.adapter.BGARecyclerViewAdapter;
import cn.bingoogolapple.androidcommon.adapter.BGAViewHolderHelper;
import project.dade.cn.bst.R;
import project.dade.cn.bst.base.ZJPBaseBarActivity;
import project.dade.cn.bst.model.IndexInfoHots;

/**
 * Created by vain zhou on 2016/8/12.
 */
public class HotsActivity extends ZJPBaseBarActivity {
    private ArrayList<IndexInfoHots> hots;
    @InjectView(R.id.list)
    RecyclerView recyclerView;
    private  HotsAdapter hotsAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_hots);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(layoutManager);
        hots=( ArrayList<IndexInfoHots> ) getIntent().getSerializableExtra("hots");
        Log.i("",hots.get(0).getDescription());
        hotsAdapter=new HotsAdapter(recyclerView);
        hotsAdapter.setDatas(hots);
        recyclerView.setAdapter(hotsAdapter);
    }
    public class  HotsAdapter extends BGARecyclerViewAdapter<IndexInfoHots>{

        public HotsAdapter(RecyclerView recyclerView) {
            super(recyclerView, R.layout.item);
        }



        @Override
        protected void fillData(BGAViewHolderHelper viewHolderHelper, int i, IndexInfoHots model) {
            ImageView avatorIv =viewHolderHelper.getView(R.id.hotRL3Icon);
            Glide.with(mContext).load(model.getProductImage()).placeholder(R.drawable.image_loader_small).error(R.drawable.image_loader_small).into(avatorIv);

            viewHolderHelper.setText(R.id.hotRL3Title, model.getProductName());
            viewHolderHelper.setText(R.id.hotRL3Small,model.getSellPrice());

        }
    }


}
